{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# kmeans聚类\n",
    "- 轮廓系数"
   ]
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:43.505780Z",
     "start_time": "2025-01-23T01:43:41.353544Z"
    }
   },
   "cell_type": "code",
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from sklearn.decomposition import PCA\n",
    "from sklearn.cluster import KMeans\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn.metrics import silhouette_score"
   ],
   "outputs": [],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:48.444757Z",
     "start_time": "2025-01-23T01:43:43.506788Z"
    }
   },
   "source": [
    "# 读取四张表的数据\n",
    "# 读取了订单和产品id的关联，csv比较大\n",
    "prior = pd.read_csv(\"./data/instacart/order_products__prior.csv\")"
   ],
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:48.485506Z",
     "start_time": "2025-01-23T01:43:48.445759Z"
    }
   },
   "source": [
    "#产品id，与过道的对应\n",
    "products = pd.read_csv(\"./data/instacart/products.csv\")"
   ],
   "outputs": [],
   "execution_count": 4
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.482741Z",
     "start_time": "2025-01-23T01:43:48.486511Z"
    }
   },
   "source": [
    "#订单id和用户id的对应，csv比较大\n",
    "orders = pd.read_csv(\"./data/instacart/orders.csv\")"
   ],
   "outputs": [],
   "execution_count": 5
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.487568Z",
     "start_time": "2025-01-23T01:43:49.483743Z"
    }
   },
   "source": [
    "#超市的过道，过道放的产品的品类\n",
    "aisles = pd.read_csv(\"./data/instacart/aisles.csv\")"
   ],
   "outputs": [],
   "execution_count": 6
  },
  {
   "cell_type": "code",
   "source": [
    "prior.head()  #订单id，产品id，下面只需要掌握订单和产品的关联即可"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.499219Z",
     "start_time": "2025-01-23T01:43:49.487568Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   order_id  product_id  add_to_cart_order  reordered\n",
       "0         2       33120                  1          1\n",
       "1         2       28985                  2          1\n",
       "2         2        9327                  3          0\n",
       "3         2       45918                  4          1\n",
       "4         2       30035                  5          0"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>product_id</th>\n",
       "      <th>add_to_cart_order</th>\n",
       "      <th>reordered</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>33120</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>28985</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>9327</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>45918</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>30035</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "cell_type": "code",
   "source": [
    "products.head() #产品id，产品名称，过道id"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.505031Z",
     "start_time": "2025-01-23T01:43:49.499219Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   product_id                                       product_name  aisle_id  \\\n",
       "0           1                         Chocolate Sandwich Cookies        61   \n",
       "1           2                                   All-Seasons Salt       104   \n",
       "2           3               Robust Golden Unsweetened Oolong Tea        94   \n",
       "3           4  Smart Ones Classic Favorites Mini Rigatoni Wit...        38   \n",
       "4           5                          Green Chile Anytime Sauce         5   \n",
       "\n",
       "   department_id  \n",
       "0             19  \n",
       "1             13  \n",
       "2              7  \n",
       "3              1  \n",
       "4             13  "
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>product_id</th>\n",
       "      <th>product_name</th>\n",
       "      <th>aisle_id</th>\n",
       "      <th>department_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Chocolate Sandwich Cookies</td>\n",
       "      <td>61</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>All-Seasons Salt</td>\n",
       "      <td>104</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Robust Golden Unsweetened Oolong Tea</td>\n",
       "      <td>94</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Smart Ones Classic Favorites Mini Rigatoni Wit...</td>\n",
       "      <td>38</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Green Chile Anytime Sauce</td>\n",
       "      <td>5</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 8
  },
  {
   "cell_type": "code",
   "source": [
    "orders.head() #订单id，用户id"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.514024Z",
     "start_time": "2025-01-23T01:43:49.505031Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   order_id  user_id eval_set  order_number  order_dow  order_hour_of_day  \\\n",
       "0   2539329        1    prior             1          2                  8   \n",
       "1   2398795        1    prior             2          3                  7   \n",
       "2    473747        1    prior             3          3                 12   \n",
       "3   2254736        1    prior             4          4                  7   \n",
       "4    431534        1    prior             5          4                 15   \n",
       "\n",
       "   days_since_prior_order  \n",
       "0                     NaN  \n",
       "1                    15.0  \n",
       "2                    21.0  \n",
       "3                    29.0  \n",
       "4                    28.0  "
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>eval_set</th>\n",
       "      <th>order_number</th>\n",
       "      <th>order_dow</th>\n",
       "      <th>order_hour_of_day</th>\n",
       "      <th>days_since_prior_order</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2539329</td>\n",
       "      <td>1</td>\n",
       "      <td>prior</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>8</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2398795</td>\n",
       "      <td>1</td>\n",
       "      <td>prior</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>7</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>473747</td>\n",
       "      <td>1</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>12</td>\n",
       "      <td>21.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2254736</td>\n",
       "      <td>1</td>\n",
       "      <td>prior</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>29.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>431534</td>\n",
       "      <td>1</td>\n",
       "      <td>prior</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>15</td>\n",
       "      <td>28.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 9
  },
  {
   "cell_type": "code",
   "source": [
    "aisles.head() #过道id，对应过道里放了哪些产品类别"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:43:49.521745Z",
     "start_time": "2025-01-23T01:43:49.515025Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   aisle_id                       aisle\n",
       "0         1       prepared soups salads\n",
       "1         2           specialty cheeses\n",
       "2         3         energy granola bars\n",
       "3         4               instant foods\n",
       "4         5  marinades meat preparation"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>aisle_id</th>\n",
       "      <th>aisle</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>prepared soups salads</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>specialty cheeses</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>energy granola bars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>instant foods</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>marinades meat preparation</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:44:11.587271Z",
     "start_time": "2025-01-23T01:43:49.523750Z"
    }
   },
   "source": [
    "# 合并四张表到一张表  （用户-物品类别），在这里挂了，用下阿里云\n",
    "# 订单表和产品表关联\n",
    "# 用户买了哪些订单，订单里面有哪些产品，产品对应的过道，过道对应的产品类别\n",
    "_mg = pd.merge(prior, products, on=['product_id', 'product_id'])\n",
    "_mg = pd.merge(_mg, orders, on=['order_id', 'order_id'])\n",
    "mt = pd.merge(_mg, aisles, on=['aisle_id', 'aisle_id'])"
   ],
   "outputs": [],
   "execution_count": 11
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:44:11.643012Z",
     "start_time": "2025-01-23T01:44:11.598273Z"
    }
   },
   "source": [
    "mt.head(10)"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   order_id  product_id  add_to_cart_order  reordered  \\\n",
       "0         2       33120                  1          1   \n",
       "1         2       28985                  2          1   \n",
       "2         2        9327                  3          0   \n",
       "3         2       45918                  4          1   \n",
       "4         2       30035                  5          0   \n",
       "5         2       17794                  6          1   \n",
       "6         2       40141                  7          1   \n",
       "7         2        1819                  8          1   \n",
       "8         2       43668                  9          0   \n",
       "9         3       33754                  1          1   \n",
       "\n",
       "                                        product_name  aisle_id  department_id  \\\n",
       "0                                 Organic Egg Whites        86             16   \n",
       "1                              Michigan Organic Kale        83              4   \n",
       "2                                      Garlic Powder       104             13   \n",
       "3                                     Coconut Butter        19             13   \n",
       "4                                  Natural Sweetener        17             13   \n",
       "5                                            Carrots        83              4   \n",
       "6                   Original Unflavored Gelatine Mix       105             13   \n",
       "7           All Natural No Stir Creamy Almond Butter        88             13   \n",
       "8                            Classic Blend Cole Slaw       123              4   \n",
       "9  Total 2% with Strawberry Lowfat Greek Strained...       120             16   \n",
       "\n",
       "   user_id eval_set  order_number  order_dow  order_hour_of_day  \\\n",
       "0   202279    prior             3          5                  9   \n",
       "1   202279    prior             3          5                  9   \n",
       "2   202279    prior             3          5                  9   \n",
       "3   202279    prior             3          5                  9   \n",
       "4   202279    prior             3          5                  9   \n",
       "5   202279    prior             3          5                  9   \n",
       "6   202279    prior             3          5                  9   \n",
       "7   202279    prior             3          5                  9   \n",
       "8   202279    prior             3          5                  9   \n",
       "9   205970    prior            16          5                 17   \n",
       "\n",
       "   days_since_prior_order                       aisle  \n",
       "0                     8.0                        eggs  \n",
       "1                     8.0            fresh vegetables  \n",
       "2                     8.0           spices seasonings  \n",
       "3                     8.0               oils vinegars  \n",
       "4                     8.0          baking ingredients  \n",
       "5                     8.0            fresh vegetables  \n",
       "6                     8.0  doughs gelatins bake mixes  \n",
       "7                     8.0                     spreads  \n",
       "8                     8.0  packaged vegetables fruits  \n",
       "9                    12.0                      yogurt  "
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>product_id</th>\n",
       "      <th>add_to_cart_order</th>\n",
       "      <th>reordered</th>\n",
       "      <th>product_name</th>\n",
       "      <th>aisle_id</th>\n",
       "      <th>department_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>eval_set</th>\n",
       "      <th>order_number</th>\n",
       "      <th>order_dow</th>\n",
       "      <th>order_hour_of_day</th>\n",
       "      <th>days_since_prior_order</th>\n",
       "      <th>aisle</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>33120</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Organic Egg Whites</td>\n",
       "      <td>86</td>\n",
       "      <td>16</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>eggs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>28985</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>Michigan Organic Kale</td>\n",
       "      <td>83</td>\n",
       "      <td>4</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>fresh vegetables</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>9327</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>Garlic Powder</td>\n",
       "      <td>104</td>\n",
       "      <td>13</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>spices seasonings</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>45918</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>Coconut Butter</td>\n",
       "      <td>19</td>\n",
       "      <td>13</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>oils vinegars</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>30035</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Natural Sweetener</td>\n",
       "      <td>17</td>\n",
       "      <td>13</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>baking ingredients</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>17794</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>Carrots</td>\n",
       "      <td>83</td>\n",
       "      <td>4</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>fresh vegetables</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>40141</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>Original Unflavored Gelatine Mix</td>\n",
       "      <td>105</td>\n",
       "      <td>13</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>doughs gelatins bake mixes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>1819</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>All Natural No Stir Creamy Almond Butter</td>\n",
       "      <td>88</td>\n",
       "      <td>13</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>spreads</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2</td>\n",
       "      <td>43668</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>Classic Blend Cole Slaw</td>\n",
       "      <td>123</td>\n",
       "      <td>4</td>\n",
       "      <td>202279</td>\n",
       "      <td>prior</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>9</td>\n",
       "      <td>8.0</td>\n",
       "      <td>packaged vegetables fruits</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>3</td>\n",
       "      <td>33754</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>Total 2% with Strawberry Lowfat Greek Strained...</td>\n",
       "      <td>120</td>\n",
       "      <td>16</td>\n",
       "      <td>205970</td>\n",
       "      <td>prior</td>\n",
       "      <td>16</td>\n",
       "      <td>5</td>\n",
       "      <td>17</td>\n",
       "      <td>12.0</td>\n",
       "      <td>yogurt</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 12
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:44:11.651791Z",
     "start_time": "2025-01-23T01:44:11.644021Z"
    }
   },
   "source": [
    "mt.shape"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(32434489, 14)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 13
  },
  {
   "cell_type": "code",
   "source": "mt.isnull().sum()/mt.shape[0]  # 数据缺失率，没有缺失值",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2025-01-23T01:44:14.130426Z",
     "start_time": "2025-01-23T01:44:11.652795Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "order_id                  0.00000\n",
       "product_id                0.00000\n",
       "add_to_cart_order         0.00000\n",
       "reordered                 0.00000\n",
       "product_name              0.00000\n",
       "aisle_id                  0.00000\n",
       "department_id             0.00000\n",
       "user_id                   0.00000\n",
       "eval_set                  0.00000\n",
       "order_number              0.00000\n",
       "order_dow                 0.00000\n",
       "order_hour_of_day         0.00000\n",
       "days_since_prior_order    0.06407\n",
       "aisle                     0.00000\n",
       "dtype: float64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 14
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.092943Z",
     "start_time": "2025-01-23T01:44:14.131428Z"
    }
   },
   "source": [
    "# 交叉表（特殊的分组工具），如果在这一步内存不够了，重启一下jupyter，还是不行，筛选一部分用户的数据，进行聚类\n",
    "# 将原始数据转换为一个矩阵形式，其中行代表用户，列代表商品类别，单元格中的值表示用户在该商品类别上的购买次数。\n",
    "cross = pd.crosstab(mt['user_id'], mt['aisle'])"
   ],
   "outputs": [],
   "execution_count": 15
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.103754Z",
     "start_time": "2025-01-23T01:45:05.093946Z"
    }
   },
   "source": [
    "cross.head(10)"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "aisle    air fresheners candles  asian foods  baby accessories  \\\n",
       "user_id                                                          \n",
       "1                             0            0                 0   \n",
       "2                             0            3                 0   \n",
       "3                             0            0                 0   \n",
       "4                             0            0                 0   \n",
       "5                             0            2                 0   \n",
       "6                             0            0                 0   \n",
       "7                             0            0                 0   \n",
       "8                             0            1                 0   \n",
       "9                             0            0                 0   \n",
       "10                            0            1                 0   \n",
       "\n",
       "aisle    baby bath body care  baby food formula  bakery desserts  \\\n",
       "user_id                                                            \n",
       "1                          0                  0                0   \n",
       "2                          0                  0                0   \n",
       "3                          0                  0                0   \n",
       "4                          0                  0                0   \n",
       "5                          0                  0                0   \n",
       "6                          0                  0                0   \n",
       "7                          0                  0                0   \n",
       "8                          0                  0                0   \n",
       "9                          0                  6                0   \n",
       "10                         0                  0                0   \n",
       "\n",
       "aisle    baking ingredients  baking supplies decor  beauty  beers coolers  \\\n",
       "user_id                                                                     \n",
       "1                         0                      0       0              0   \n",
       "2                         2                      0       0              0   \n",
       "3                         0                      0       0              0   \n",
       "4                         0                      0       0              0   \n",
       "5                         0                      0       0              0   \n",
       "6                         0                      0       0              0   \n",
       "7                         2                      0       0              0   \n",
       "8                         1                      0       0              0   \n",
       "9                         2                      0       0              0   \n",
       "10                        0                      0       0              0   \n",
       "\n",
       "aisle    ...  spreads  tea  tofu meat alternatives  tortillas flat bread  \\\n",
       "user_id  ...                                                               \n",
       "1        ...        1    0                       0                     0   \n",
       "2        ...        3    1                       1                     0   \n",
       "3        ...        4    1                       0                     0   \n",
       "4        ...        0    0                       0                     1   \n",
       "5        ...        0    0                       0                     0   \n",
       "6        ...        0    0                       0                     0   \n",
       "7        ...        0    0                       0                     0   \n",
       "8        ...        0    0                       0                     0   \n",
       "9        ...        0    0                       0                     0   \n",
       "10       ...        0    0                       0                     0   \n",
       "\n",
       "aisle    trail mix snack mix  trash bags liners  vitamins supplements  \\\n",
       "user_id                                                                 \n",
       "1                          0                  0                     0   \n",
       "2                          0                  0                     0   \n",
       "3                          0                  0                     0   \n",
       "4                          0                  0                     0   \n",
       "5                          0                  0                     0   \n",
       "6                          0                  0                     0   \n",
       "7                          0                  0                     0   \n",
       "8                          0                  0                     0   \n",
       "9                          0                  0                     0   \n",
       "10                         0                  0                     0   \n",
       "\n",
       "aisle    water seltzer sparkling water  white wines  yogurt  \n",
       "user_id                                                      \n",
       "1                                    0            0       1  \n",
       "2                                    2            0      42  \n",
       "3                                    2            0       0  \n",
       "4                                    1            0       0  \n",
       "5                                    0            0       3  \n",
       "6                                    0            0       0  \n",
       "7                                    0            0       5  \n",
       "8                                    0            0       0  \n",
       "9                                    2            0      19  \n",
       "10                                   0            0       2  \n",
       "\n",
       "[10 rows x 134 columns]"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>aisle</th>\n",
       "      <th>air fresheners candles</th>\n",
       "      <th>asian foods</th>\n",
       "      <th>baby accessories</th>\n",
       "      <th>baby bath body care</th>\n",
       "      <th>baby food formula</th>\n",
       "      <th>bakery desserts</th>\n",
       "      <th>baking ingredients</th>\n",
       "      <th>baking supplies decor</th>\n",
       "      <th>beauty</th>\n",
       "      <th>beers coolers</th>\n",
       "      <th>...</th>\n",
       "      <th>spreads</th>\n",
       "      <th>tea</th>\n",
       "      <th>tofu meat alternatives</th>\n",
       "      <th>tortillas flat bread</th>\n",
       "      <th>trail mix snack mix</th>\n",
       "      <th>trash bags liners</th>\n",
       "      <th>vitamins supplements</th>\n",
       "      <th>water seltzer sparkling water</th>\n",
       "      <th>white wines</th>\n",
       "      <th>yogurt</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>user_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 134 columns</p>\n",
       "</div>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 16
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.109869Z",
     "start_time": "2025-01-23T01:45:05.103754Z"
    }
   },
   "source": [
    "# 针对20万用户，有134个特征\n",
    "cross.shape"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(206209, 134)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 17
  },
  {
   "cell_type": "code",
   "source": [
    "type(cross)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.115861Z",
     "start_time": "2025-01-23T01:45:05.109869Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 18
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.121073Z",
     "start_time": "2025-01-23T01:45:05.115861Z"
    }
   },
   "source": [
    "# 进行主成分分析,那么大家还记得不？，保留90%的成分，实际特征数目减少了几倍，134--》27（不一定要用，看效果）\n",
    "pca = PCA(n_components=0.9)"
   ],
   "outputs": [],
   "execution_count": 19
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.431120Z",
     "start_time": "2025-01-23T01:45:05.121073Z"
    }
   },
   "source": [
    "data = pca.fit_transform(cross)  #还记得fit_transform的作用不？\n",
    "data.shape"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(206209, 27)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 20
  },
  {
   "cell_type": "code",
   "source": [
    "type(data)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.435096Z",
     "start_time": "2025-01-23T01:45:05.431120Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.ndarray"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 21
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.441318Z",
     "start_time": "2025-01-23T01:45:05.435096Z"
    }
   },
   "source": [
    "# 把样本数量减少,为了下面画图方便，这里只取500个样本\n",
    "x = data[:500]\n",
    "x.shape"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(500, 27)"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 22
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.448636Z",
     "start_time": "2025-01-23T01:45:05.441318Z"
    }
   },
   "source": [
    "x[0:10]"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-2.42156587e+01, -2.42942720e+00, -2.46636975e+00,\n",
       "         1.45686388e-01,  2.69042476e-01, -1.43293209e+00,\n",
       "        -2.14067666e+00,  2.73803122e+00, -2.71431623e+00,\n",
       "        -1.74313529e+00, -1.13632718e+00,  6.73601069e-01,\n",
       "        -1.65070735e+00,  2.83802486e+00,  5.89384489e+00,\n",
       "        -7.84312891e+00, -4.84010146e+00, -3.22598697e+00,\n",
       "        -4.58007571e+00,  7.77403349e-01, -3.69912893e+00,\n",
       "         1.90721439e+00, -2.99538594e+00, -7.72922878e-01,\n",
       "         6.86800336e-01,  1.69439402e+00, -2.34323022e+00],\n",
       "       [ 6.46320806e+00, -3.67511165e+01,  8.38255336e+00,\n",
       "        -1.50975303e+01, -6.92093785e+00, -9.78375183e-01,\n",
       "        -6.01156653e+00, -3.78772465e+00, -8.18074883e+00,\n",
       "        -9.04086141e+00, -5.61352902e+00, -1.11325323e+00,\n",
       "         2.96702911e+00, -4.73123497e+00, -9.11472283e+00,\n",
       "        -2.14709471e-01,  1.29694031e+00, -7.37605505e-01,\n",
       "        -7.37401979e-01,  7.40042249e-01, -9.13382968e-02,\n",
       "         5.15128465e+00,  4.58481528e+00,  3.23789431e+00,\n",
       "         4.12121252e+00,  2.44689740e+00, -4.28348478e+00],\n",
       "       [-7.99030162e+00, -2.40438257e+00, -1.10300641e+01,\n",
       "        -6.72230096e-01, -4.42368029e-01, -2.82327194e+00,\n",
       "         6.28414012e+00, -6.51250946e+00, -2.14863353e+00,\n",
       "        -1.58525733e+00,  8.28813958e+00, -2.66151647e+00,\n",
       "        -4.50773836e+00,  1.19764737e+00,  6.93186953e-01,\n",
       "        -2.03281164e+00, -2.15050796e+00,  5.43473349e+00,\n",
       "        -3.60484175e+00,  4.28279419e+00, -4.45833616e-01,\n",
       "         3.03933749e+00,  1.46956568e+00,  2.94665603e+00,\n",
       "         1.77534453e+00, -4.44194030e-01,  7.86665571e-01],\n",
       "       [-2.79911291e+01,  7.55822760e-01, -1.92173207e+00,\n",
       "        -2.09188771e+00, -2.88231934e-01,  9.26177341e-01,\n",
       "        -8.27127057e-01, -6.14848545e-01,  3.78198802e-02,\n",
       "        -8.90672448e-01, -3.72088202e-01, -9.85771637e-01,\n",
       "         1.22495060e+00, -1.09639889e+00, -1.87159972e+00,\n",
       "        -7.10463022e-01,  6.75146395e-01, -2.62095591e-01,\n",
       "        -7.10689458e-02, -2.28812201e-01, -6.06522210e-01,\n",
       "         3.67203966e-01, -9.98709579e-01,  1.77374812e-01,\n",
       "         7.54646031e-01,  1.35817221e-01, -5.00043313e-01],\n",
       "       [-1.98963936e+01,  2.63722464e+00,  5.33228944e-01,\n",
       "        -3.67922837e+00,  6.12824980e-01, -1.62400824e+00,\n",
       "         3.93577123e+00, -2.00462740e+00,  1.00208961e+00,\n",
       "         3.08574683e+00, -5.50145774e-01,  2.87433706e-01,\n",
       "         4.11277359e-01, -2.64715919e+00,  6.28331685e-02,\n",
       "         1.65193116e-01, -4.81514320e-01,  1.64452919e+00,\n",
       "        -4.03108796e-01,  1.36899942e-01, -2.57981162e-01,\n",
       "         2.05400491e-01, -2.83754054e-01, -3.83840932e-01,\n",
       "        -1.93524072e-01, -6.45446295e-03, -2.08896003e-01],\n",
       "       [-2.64697723e+01,  4.68042570e+00,  4.64557305e-01,\n",
       "        -2.91452624e+00,  2.76753747e-01,  4.50849758e-01,\n",
       "         6.17645819e-01, -1.36215062e+00, -8.78502640e-02,\n",
       "         1.04054593e+00, -1.29224191e-02, -7.72674027e-01,\n",
       "        -1.05021630e+00, -3.84457799e-01, -6.50245651e-01,\n",
       "        -6.13803784e-01, -3.15793193e-01,  4.45930153e-01,\n",
       "        -3.11288889e-01,  2.86938163e-01, -1.07310998e-01,\n",
       "         6.65099620e-02, -1.56723355e-01, -1.59418792e-01,\n",
       "        -8.45564389e-02, -3.76327213e-01, -1.50797713e-01],\n",
       "       [ 6.43209799e+00, -5.20763684e+00, -5.37622059e+00,\n",
       "         5.03559798e+00, -1.55767996e+00, -7.73522520e+00,\n",
       "        -3.65929977e+00, -1.36194664e+01,  1.99127136e+01,\n",
       "        -3.87327108e+00,  2.10011278e+00, -2.67040732e+00,\n",
       "        -3.92512694e+00,  2.84756844e+00, -2.99126238e+00,\n",
       "        -4.13848691e+00,  4.59204143e+00,  2.66185949e+00,\n",
       "        -3.19197384e+00,  1.21530631e+00, -1.45136887e+00,\n",
       "         2.61171430e+00,  5.35780919e+00, -1.67350589e-01,\n",
       "         3.68044142e+00,  5.13104043e+00, -2.44269167e+00],\n",
       "       [-1.47587512e+01,  1.48684622e+01,  5.26133999e+00,\n",
       "        -2.72312827e+00, -4.41192804e-01,  1.77040069e+00,\n",
       "        -1.74849912e+00,  3.44199907e-01, -4.91075999e-01,\n",
       "         7.21488180e-01, -2.07273731e-01, -8.11480837e-01,\n",
       "        -1.49222116e+00,  6.44199120e-01, -7.40158282e-01,\n",
       "        -1.66319300e+00, -7.31046033e-01,  1.27234895e+00,\n",
       "        -7.04458786e-01, -1.38317595e-01,  4.33882990e-01,\n",
       "        -1.18706848e+00,  3.63571463e-01, -3.12302788e-01,\n",
       "         1.08780259e+00, -7.86800582e-01, -1.10628088e+00],\n",
       "       [-1.96448729e+01, -1.26189013e+01,  9.83832433e+00,\n",
       "        -5.96574917e+00,  3.25687125e+00,  2.32791585e+00,\n",
       "        -6.73245565e-03, -3.08230596e+00, -2.02937972e+00,\n",
       "        -2.19119257e+00, -5.76293826e-01,  2.98996645e+00,\n",
       "        -2.47415700e+00, -2.88953834e+00, -3.31359457e-01,\n",
       "        -1.21583350e-01,  1.46034805e+00, -1.54383264e+00,\n",
       "        -2.46265921e+00, -9.20833430e-01, -2.09191478e+00,\n",
       "         6.57037453e-02, -1.15878119e+00, -4.98714845e-01,\n",
       "         6.28224832e-01, -8.20937502e-01, -1.02610380e+00],\n",
       "       [ 4.06313864e+00,  1.54398182e+01,  2.77360399e+00,\n",
       "        -1.84179405e+00,  7.00877536e-01, -3.93387952e+00,\n",
       "         3.89695552e+00, -9.00116964e-01, -2.15791311e+00,\n",
       "         6.78592732e-01, -7.31465145e+00, -3.25791681e+00,\n",
       "        -4.73315648e+00,  1.19352292e+00, -1.62849209e+00,\n",
       "        -3.81328812e+00, -1.68239105e+00,  2.85570315e+00,\n",
       "        -8.93176379e-01, -2.53824756e+00, -1.41322471e-01,\n",
       "         4.26790007e-01,  4.48191235e+00, -3.74732433e+00,\n",
       "        -1.03797787e+00, -9.22191838e-01, -7.55201486e+00]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 23
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.454821Z",
     "start_time": "2025-01-23T01:45:05.448636Z"
    }
   },
   "source": [
    "x.max()"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(407.18563418249795)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 24
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.460715Z",
     "start_time": "2025-01-23T01:45:05.454821Z"
    }
   },
   "source": [
    "x.min()"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(-144.56766126863653)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 25
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.465804Z",
     "start_time": "2025-01-23T01:45:05.460715Z"
    }
   },
   "source": [
    "# 假设用户一共分为四个类别\n",
    "# n_clusters是分为几个类别，是主要的超参\n",
    "km = KMeans(n_clusters=4)"
   ],
   "outputs": [],
   "execution_count": 26
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.722004Z",
     "start_time": "2025-01-23T01:45:05.465804Z"
    }
   },
   "source": [
    "km.fit(x)  #开始训练"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "KMeans(n_clusters=4)"
      ],
      "text/html": [
       "<style>#sk-container-id-1 {\n",
       "  /* Definition of color scheme common for light and dark mode */\n",
       "  --sklearn-color-text: #000;\n",
       "  --sklearn-color-text-muted: #666;\n",
       "  --sklearn-color-line: gray;\n",
       "  /* Definition of color scheme for unfitted estimators */\n",
       "  --sklearn-color-unfitted-level-0: #fff5e6;\n",
       "  --sklearn-color-unfitted-level-1: #f6e4d2;\n",
       "  --sklearn-color-unfitted-level-2: #ffe0b3;\n",
       "  --sklearn-color-unfitted-level-3: chocolate;\n",
       "  /* Definition of color scheme for fitted estimators */\n",
       "  --sklearn-color-fitted-level-0: #f0f8ff;\n",
       "  --sklearn-color-fitted-level-1: #d4ebff;\n",
       "  --sklearn-color-fitted-level-2: #b3dbfd;\n",
       "  --sklearn-color-fitted-level-3: cornflowerblue;\n",
       "\n",
       "  /* Specific color for light theme */\n",
       "  --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
       "  --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
       "  --sklearn-color-icon: #696969;\n",
       "\n",
       "  @media (prefers-color-scheme: dark) {\n",
       "    /* Redefinition of color scheme for dark theme */\n",
       "    --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
       "    --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
       "    --sklearn-color-icon: #878787;\n",
       "  }\n",
       "}\n",
       "\n",
       "#sk-container-id-1 {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 pre {\n",
       "  padding: 0;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-hidden--visually {\n",
       "  border: 0;\n",
       "  clip: rect(1px 1px 1px 1px);\n",
       "  clip: rect(1px, 1px, 1px, 1px);\n",
       "  height: 1px;\n",
       "  margin: -1px;\n",
       "  overflow: hidden;\n",
       "  padding: 0;\n",
       "  position: absolute;\n",
       "  width: 1px;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-dashed-wrapped {\n",
       "  border: 1px dashed var(--sklearn-color-line);\n",
       "  margin: 0 0.4em 0.5em 0.4em;\n",
       "  box-sizing: border-box;\n",
       "  padding-bottom: 0.4em;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-container {\n",
       "  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
       "     but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
       "     so we also need the `!important` here to be able to override the\n",
       "     default hidden behavior on the sphinx rendered scikit-learn.org.\n",
       "     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
       "  display: inline-block !important;\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-text-repr-fallback {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       "div.sk-parallel-item,\n",
       "div.sk-serial,\n",
       "div.sk-item {\n",
       "  /* draw centered vertical line to link estimators */\n",
       "  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
       "  background-size: 2px 100%;\n",
       "  background-repeat: no-repeat;\n",
       "  background-position: center center;\n",
       "}\n",
       "\n",
       "/* Parallel-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item::after {\n",
       "  content: \"\";\n",
       "  width: 100%;\n",
       "  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
       "  flex-grow: 1;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel {\n",
       "  display: flex;\n",
       "  align-items: stretch;\n",
       "  justify-content: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  position: relative;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
       "  align-self: flex-end;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
       "  align-self: flex-start;\n",
       "  width: 50%;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
       "  width: 0;\n",
       "}\n",
       "\n",
       "/* Serial-specific style estimator block */\n",
       "\n",
       "#sk-container-id-1 div.sk-serial {\n",
       "  display: flex;\n",
       "  flex-direction: column;\n",
       "  align-items: center;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  padding-right: 1em;\n",
       "  padding-left: 1em;\n",
       "}\n",
       "\n",
       "\n",
       "/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
       "clickable and can be expanded/collapsed.\n",
       "- Pipeline and ColumnTransformer use this feature and define the default style\n",
       "- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
       "*/\n",
       "\n",
       "/* Pipeline and ColumnTransformer style (default) */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable {\n",
       "  /* Default theme specific background. It is overwritten whether we have a\n",
       "  specific estimator or a Pipeline/ColumnTransformer */\n",
       "  background-color: var(--sklearn-color-background);\n",
       "}\n",
       "\n",
       "/* Toggleable label */\n",
       "#sk-container-id-1 label.sk-toggleable__label {\n",
       "  cursor: pointer;\n",
       "  display: flex;\n",
       "  width: 100%;\n",
       "  margin-bottom: 0;\n",
       "  padding: 0.5em;\n",
       "  box-sizing: border-box;\n",
       "  text-align: center;\n",
       "  align-items: start;\n",
       "  justify-content: space-between;\n",
       "  gap: 0.5em;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label .caption {\n",
       "  font-size: 0.6rem;\n",
       "  font-weight: lighter;\n",
       "  color: var(--sklearn-color-text-muted);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
       "  /* Arrow on the left of the label */\n",
       "  content: \"▸\";\n",
       "  float: left;\n",
       "  margin-right: 0.25em;\n",
       "  color: var(--sklearn-color-icon);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
       "  color: var(--sklearn-color-text);\n",
       "}\n",
       "\n",
       "/* Toggleable content - dropdown */\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content {\n",
       "  max-height: 0;\n",
       "  max-width: 0;\n",
       "  overflow: hidden;\n",
       "  text-align: left;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content pre {\n",
       "  margin: 0.2em;\n",
       "  border-radius: 0.25em;\n",
       "  color: var(--sklearn-color-text);\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
       "  /* Expand drop-down */\n",
       "  max-height: 200px;\n",
       "  max-width: 100%;\n",
       "  overflow: auto;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
       "  content: \"▾\";\n",
       "}\n",
       "\n",
       "/* Pipeline/ColumnTransformer-specific style */\n",
       "\n",
       "#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator-specific style */\n",
       "\n",
       "/* Colorize estimator box */\n",
       "#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  /* The background is the default theme color */\n",
       "  color: var(--sklearn-color-text-on-default-background);\n",
       "}\n",
       "\n",
       "/* On hover, darken the color of the background */\n",
       "#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "/* Label box, darken color on hover, fitted */\n",
       "#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
       "  color: var(--sklearn-color-text);\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Estimator label */\n",
       "\n",
       "#sk-container-id-1 div.sk-label label {\n",
       "  font-family: monospace;\n",
       "  font-weight: bold;\n",
       "  display: inline-block;\n",
       "  line-height: 1.2em;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-label-container {\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       "/* Estimator-specific */\n",
       "#sk-container-id-1 div.sk-estimator {\n",
       "  font-family: monospace;\n",
       "  border: 1px dotted var(--sklearn-color-border-box);\n",
       "  border-radius: 0.25em;\n",
       "  box-sizing: border-box;\n",
       "  margin-bottom: 0.5em;\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-0);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-0);\n",
       "}\n",
       "\n",
       "/* on hover */\n",
       "#sk-container-id-1 div.sk-estimator:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-2);\n",
       "}\n",
       "\n",
       "#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-2);\n",
       "}\n",
       "\n",
       "/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
       "\n",
       "/* Common style for \"i\" and \"?\" */\n",
       "\n",
       ".sk-estimator-doc-link,\n",
       "a:link.sk-estimator-doc-link,\n",
       "a:visited.sk-estimator-doc-link {\n",
       "  float: right;\n",
       "  font-size: smaller;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1em;\n",
       "  height: 1em;\n",
       "  width: 1em;\n",
       "  text-decoration: none !important;\n",
       "  margin-left: 0.5em;\n",
       "  text-align: center;\n",
       "  /* unfitted */\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted,\n",
       "a:link.sk-estimator-doc-link.fitted,\n",
       "a:visited.sk-estimator-doc-link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
       ".sk-estimator-doc-link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover,\n",
       "div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
       ".sk-estimator-doc-link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "/* Span, style for the box shown on hovering the info icon */\n",
       ".sk-estimator-doc-link span {\n",
       "  display: none;\n",
       "  z-index: 9999;\n",
       "  position: relative;\n",
       "  font-weight: normal;\n",
       "  right: .2ex;\n",
       "  padding: .5ex;\n",
       "  margin: .5ex;\n",
       "  width: min-content;\n",
       "  min-width: 20ex;\n",
       "  max-width: 50ex;\n",
       "  color: var(--sklearn-color-text);\n",
       "  box-shadow: 2pt 2pt 4pt #999;\n",
       "  /* unfitted */\n",
       "  background: var(--sklearn-color-unfitted-level-0);\n",
       "  border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link.fitted span {\n",
       "  /* fitted */\n",
       "  background: var(--sklearn-color-fitted-level-0);\n",
       "  border: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "\n",
       ".sk-estimator-doc-link:hover span {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       "/* \"?\"-specific style due to the `<a>` HTML tag */\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link {\n",
       "  float: right;\n",
       "  font-size: 1rem;\n",
       "  line-height: 1em;\n",
       "  font-family: monospace;\n",
       "  background-color: var(--sklearn-color-background);\n",
       "  border-radius: 1rem;\n",
       "  height: 1rem;\n",
       "  width: 1rem;\n",
       "  text-decoration: none;\n",
       "  /* unfitted */\n",
       "  color: var(--sklearn-color-unfitted-level-1);\n",
       "  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted {\n",
       "  /* fitted */\n",
       "  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
       "  color: var(--sklearn-color-fitted-level-1);\n",
       "}\n",
       "\n",
       "/* On hover */\n",
       "#sk-container-id-1 a.estimator_doc_link:hover {\n",
       "  /* unfitted */\n",
       "  background-color: var(--sklearn-color-unfitted-level-3);\n",
       "  color: var(--sklearn-color-background);\n",
       "  text-decoration: none;\n",
       "}\n",
       "\n",
       "#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
       "  /* fitted */\n",
       "  background-color: var(--sklearn-color-fitted-level-3);\n",
       "}\n",
       "</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>KMeans(n_clusters=4)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>KMeans</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.6/modules/generated/sklearn.cluster.KMeans.html\">?<span>Documentation for KMeans</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\"><pre>KMeans(n_clusters=4)</pre></div> </div></div></div></div>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 27
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.728281Z",
     "start_time": "2025-01-23T01:45:05.723006Z"
    }
   },
   "source": [
    "#开始预测\n",
    "predict = km.predict(x)"
   ],
   "outputs": [],
   "execution_count": 28
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.734671Z",
     "start_time": "2025-01-23T01:45:05.731284Z"
    }
   },
   "source": [
    "print(predict)  #预测得到的是每一个样本的类别"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1\n",
      " 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1\n",
      " 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1\n",
      " 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 0 1 1 1 0 1 1\n",
      " 1 1 1 0 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1\n",
      " 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 1 1 2 1 1 1 2 1 1 1 1 0 1 1 1\n",
      " 0 1 1 1 2 1 1 1 1 2 0 0 1 0 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1\n",
      " 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1 1 2 0 1 1 1 1 1 1\n",
      " 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 2 1 1 1 1 1 1 1 2 1 0 1 1 1 0 1 1 1 1 1 1\n",
      " 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
      " 1 1 2 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 2 1 1 1 1 0 1 1 1 1\n",
      " 1 2 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 3\n",
      " 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2\n",
      " 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1]\n"
     ]
    }
   ],
   "execution_count": 29
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.741993Z",
     "start_time": "2025-01-23T01:45:05.734671Z"
    }
   },
   "source": [
    "import numpy as np\n",
    "np.unique(predict)"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3], dtype=int32)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 30
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.780615Z",
     "start_time": "2025-01-23T01:45:05.742996Z"
    }
   },
   "source": [
    "# 显示聚类的结果\n",
    "plt.figure(figsize=(20, 20))"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 2000x2000 with 0 Axes>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 2000x2000 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 31
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.901938Z",
     "start_time": "2025-01-23T01:45:05.780615Z"
    }
   },
   "source": [
    "# 建立四个颜色的列表\n",
    "colored = ['orange', 'green', 'blue', 'purple']\n",
    "colr = [colored[i] for i in predict] #根据类别给每个样本赋予颜色\n",
    "#去选择任意两个特征来看聚类的图，可以自行调整,第2个，第20个特征\n",
    "plt.scatter(x[:, 1], x[:, 19], color=colr)  # 实际要人工去看全部特征的效果"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x2111499edb0>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGdCAYAAAA8F1jjAAAAOnRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjEwLjAsIGh0dHBzOi8vbWF0cGxvdGxpYi5vcmcvlHJYcgAAAAlwSFlzAAAPYQAAD2EBqD+naQAATyVJREFUeJzt3Qd4U2XfBvA76V60lFWgLRsB2XvIkFVxIIIoCooIIogiS8brK25RRNwC+irwKYqiIENBBZW9996jUNpCobS0dCbf9T+nKU2bpCm0yUlz/7hy0eacps/TtDl3nqkzGo1GEBEREWmQ3tkFICIiIrKGQYWIiIg0i0GFiIiINItBhYiIiDSLQYWIiIg0i0GFiIiINItBhYiIiDSLQYWIiIg0yxMuzmAwICYmBkFBQdDpdM4uDhEREdlB1ptNTk5GlSpVoNfrS29QkZASERHh7GIQERHRLYiOjkZ4eHjpDSrSkmKqaJkyZZxdHCIiIrJDUlKS0tBguo6X2qBi6u6RkMKgQkRE5FoKG7bBwbRERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkuv+AblTJJx4GErYDOA6jUBfCr7OwSERGREzGokDakxgBbhgCxf968T8JKtceBVl8AXoHOLB0RETkJgwo5X0YisLojkHLO/H5jNnD2eyD1LND1b0Dv4awSEhGRk3CMCjnfiTnA9TOAMavgMQkr8euAmN+cUTIiInIyBhVyvpNfAzBYPy5dQKfmObJERESkEQwq5HxpcbaPS6vKjQuOKg0REWkIgwo5n18V28elRcU/0lGlISIiDWFQIeerNUzSiO0WlVpP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QwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERESkWQwqREREpFkMKkRERKRZDCpERETkvkHlwoULGDRoEMqVKwc/Pz80atQIO3bsyD1uNBoxdepUVK5cWTnevXt3HD9+vKSLRURERO4eVK5evYoOHTrAy8sLK1euxKFDh/DBBx+gbNmyuedMnz4dn3zyCWbPno2tW7ciICAAUVFRSEtLK8miERERkQvQGaVJo4RMnjwZGzduxPr16y0el29dpUoVjB8/HhMmTFDuu3btGipVqoR58+ZhwIABhX6PpKQkBAcHK19XpkyZYq8DERERFT97r98l2qKybNkytGzZEv3790fFihXRrFkzfPXVV7nHT58+jdjYWKW7x0QK3aZNG2zevNniY6anpyuVy3sjIiKi0qlEg8qpU6cwa9Ys1KlTB3/88QdGjhyJ0aNHY/78+cpxCSlCWlDyks9Nx/KbNm2aEmZMt4iIiJKsAhEREZXWoGIwGNC8eXO88847SmvK8OHD8cwzzyjjUW7VlClTlGYi0y06OrpYy0xERERuElRkJk+DBg3M7qtfvz7OnTunfBwWFqb8HxcXZ3aOfG46lp+Pj4/Sl5X3RkRERKVTiQYVmfFz9OhRs/uOHTuGatWqKR/XqFFDCSRr1qzJPS5jTmT2T7t27UqyaEREROQCPEvywceOHYv27dsrXT+PPPIItm3bhi+//FK5CZ1OhzFjxuCtt95SxrFIcHnllVeUmUB9+vQpyaIRERGRuweVVq1aYcmSJcq4kjfeeEMJIh999BEGDhyYe87EiRORkpKijF9JTEzEXXfdhVWrVsHX17cki0ZERETuvo6KI3AdFSIiItejiXVUiIiIiG4HgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFpFoMKERERaRaDChEREWkWgwoRERFplsOCyrvvvgudTocxY8bk3peWloZRo0ahXLlyCAwMRL9+/RAXF+eoIhEREZHGOSSobN++HXPmzEHjxo3N7h87diyWL1+ORYsWYe3atYiJiUHfvn0dUSQiIiJyASUeVK5fv46BAwfiq6++QtmyZXPvv3btGr7++mvMnDkTXbt2RYsWLTB37lxs2rQJW7ZsKeliERERkQso8aAiXTv33Xcfunfvbnb/zp07kZmZaXZ/vXr1EBkZic2bN5d0sYiIiMgFeJbkgy9cuBC7du1Sun7yi42Nhbe3N0JCQszur1SpknLMmvT0dOVmkpSUVMylJiIiolLfohIdHY0XX3wRCxYsgK+vb7E97rRp0xAcHJx7i4iIKLbHJiIiIjcJKtK1Ex8fj+bNm8PT01O5yYDZTz75RPlYWk4yMjKQmJho9nUy6ycsLMzq406ZMkUZ32K6SSAiIiKi0qnEun66deuG/fv3m903ZMgQZRzKpEmTlJYQLy8vrFmzRpmWLI4ePYpz586hXbt2Vh/Xx8dHuREREVHpV2JBJSgoCA0bNjS7LyAgQFkzxXT/0KFDMW7cOISGhqJMmTJ44YUXlJDStm3bkioWERERuZASHUxbmA8//BB6vV5pUZEBslFRUfjiiy+cWSQiIiLSEJ3RaDTChcmsHxlUK+NVpFWGiIiISs/1m3v9EBERkWYxqBAREZFmMagQERGRZjGoEBERkWYxqBAREZFmMagQERGRZjGoEBERkWYxqBAREZFmMagQERGRZjGoEBERkWYxqBAREZFmMagQERGRZjGoEBERkWYxqB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IxUQ+AAAAAElFTkSuQmCC"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 32
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.910220Z",
     "start_time": "2025-01-23T01:45:05.901938Z"
    }
   },
   "source": [
    "# 评判聚类效果，轮廓系数，聚类效果很难超过0.7，可以通过这个得分去调整上面KMeans的n_clusters\n",
    "silhouette_score(x, predict)  # x和predict尺寸一样"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(0.6202957463496841)"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 33
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "#### 以下是练习"
  },
  {
   "cell_type": "code",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.922008Z",
     "start_time": "2025-01-23T01:45:05.910220Z"
    }
   },
   "source": [
    "# 改为2时的结果\n",
    "km = KMeans(n_clusters=2)\n",
    "km.fit(x)  #开始训练\n",
    "predict = km.predict(x)\n",
    "print(silhouette_score(x, predict))\n",
    "predict"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.70974527122164\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,\n",
       "       1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1,\n",
       "       1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1,\n",
       "       1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,\n",
       "       1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1], dtype=int32)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 34
  },
  {
   "cell_type": "code",
   "source": [
    "# 通过分类后数据，去看原始样本的特点\n",
    "cross.iloc[0]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.927050Z",
     "start_time": "2025-01-23T01:45:05.923010Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "aisle\n",
       "air fresheners candles           0\n",
       "asian foods                      0\n",
       "baby accessories                 0\n",
       "baby bath body care              0\n",
       "baby food formula                0\n",
       "                                ..\n",
       "trash bags liners                0\n",
       "vitamins supplements             0\n",
       "water seltzer sparkling water    0\n",
       "white wines                      0\n",
       "yogurt                           1\n",
       "Name: 1, Length: 134, dtype: int64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 35
  },
  {
   "cell_type": "code",
   "source": [
    "print(predict[26])\n",
    "cross.iloc[26]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.934162Z",
     "start_time": "2025-01-23T01:45:05.928055Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "aisle\n",
       "air fresheners candles             0\n",
       "asian foods                        4\n",
       "baby accessories                   0\n",
       "baby bath body care                0\n",
       "baby food formula                  0\n",
       "                                ... \n",
       "trash bags liners                  0\n",
       "vitamins supplements               0\n",
       "water seltzer sparkling water     92\n",
       "white wines                        0\n",
       "yogurt                           150\n",
       "Name: 27, Length: 134, dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 36
  },
  {
   "cell_type": "code",
   "source": [
    "# 改为3时的结果\n",
    "km = KMeans(n_clusters=3)\n",
    "km.fit(x)  #开始训练\n",
    "predict = km.predict(x)\n",
    "silhouette_score(x, predict)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    },
    "ExecuteTime": {
     "end_time": "2025-01-23T01:45:05.947301Z",
     "start_time": "2025-01-23T01:45:05.934162Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "np.float64(0.6377392240924094)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 37
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
